<?php if($_GET['act']!='discover'){?>
<div class="supportBanner" style="visibility: visible;"> 
&nbsp;
</div>
<?php }?>
<!-- 
<div class="mainMenu" style="height: 50px;">
    <a href="index.php?act=index">
        <div class="myHome <?php if($_GET['act']=='index' && $_GET['op']=='index'){ echo 'selected';}?>">首页</div>
    </a>
    <div class="publish"></div>
    <a href="index.php?act=my">
        <div class="my <?php if($_GET['act']=='my' && $_GET['op']=='index'){ echo 'selected';}?>" >我的</div>
    </a>
</div> -->
<div class="menuDiv">
 <ul>
   <a href="index.php?act=index"><li id="homeLink" <?php if($_GET['act']=='index' && $_GET['op']=='index'){?>class="on"<?php }?>>首页</li></a>
   <?php if(in_array($_GET['act'],array('index','category','discover'))){?> 
   <a href="index.php?act=category"><li id="sortLink" <?php if($_GET['act']=='category'){?>class="on"<?php }?>>分类</li></a>
   <?php }else{?>
   <a href="javascript:;" class="publish"><li id="publicLink">发布</li></a>
   <?php }?>
   <a href="index.php?act=discover"><li id="discoverLink" <?php if($_GET['act']=='discover'){?>class="on"<?php }?>>发现</li></a>
   <a href="index.php?act=my&op=index"><li id="myLink" <?php if($_GET['act']=='my' && $_GET['op']=='index'){?>class="on"<?php }?>">我的</li></a>
 </ul>
</div>
<style>
.loaddingBg {width:100%;height:100%;position:fixed;top:0px;left:0px;}
.loading1{color:#fff;width:200px;height:85px;background:rgba(0, 0, 0, 0.7);margin-left:auto;margin-right:auto;border-radius:6px;margin-left:auto;margin-right:auto;margin-top:200px;}
.loading-top {height:40px;padding-top:10px;clear:both;}
.loading-top img {margin-top:0px;margin-left:30px;float:left;}
.loading-top span{margin-top:12px;font-size:14px;float:left;}
.loading-bottom {height:30px;clear:both;}
.loading-bottom p {margin-top:3px;text-align:center;font-size:14px;}
</style>

<div class="loaddingBg" style="display:none;">
    <div class="loading1">
        <div class="loading-top"><img src="<?php echo TEMPLATE_SITE_URL;?>/images/loadingData.gif" width="45" height="45" /><span style="padding:">正上传中...</span></div>
        <div class="loading-bottom"><p><span class="readynumpic"></span>&nbsp;/&nbsp;<span class="totalpic"></span></p></div>
    </div>
</div>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
wx.config({
    appId: '<?php echo $output['signPackage']["appId"];?>',
    timestamp: <?php echo $output['signPackage']["timestamp"];?>,
    nonceStr: '<?php echo $output['signPackage']["nonceStr"];?>',
    signature: '<?php echo $output['signPackage']["signature"];?>',
   jsApiList: [
               'checkJsApi',
               'onMenuShareTimeline',
               'onMenuShareAppMessage',
               'onMenuShareQQ',
               'onMenuShareWeibo',
               'hideMenuItems',
               'showMenuItems',
               'hideAllNonBaseMenuItem',
               'showAllNonBaseMenuItem',
               'translateVoice',
               'startRecord',
               'stopRecord',
               'onRecordEnd',
               'playVoice',
               'pauseVoice',
               'stopVoice',
               'uploadVoice',
               'downloadVoice',
               'chooseImage',
               'previewImage',
               'uploadImage',
               'downloadImage',
               'getNetworkType',
               'openLocation',
               'getLocation',
               'hideOptionMenu',
               'showOptionMenu',
               'closeWindow',
               'scanQRCode',
               'chooseWXPay',
               'openProductSpecificView',
               'addCard',
               'chooseCard',
               'openCard'
      ]
  });
wx.ready(function () {
// 	wx.hideOptionMenu();
	wx.showMenuItems({
	    menuList: ["menuItem:share:appMessage","menuItem:share:timeline","menuItem:favorite","menuItem:openWithSafari","menuItem:share:email","menuItem:copyUrl","menuItem:readMode"] // 要显示的菜单项，所有menu项见附录3
	});

		

		$('#pop').click(function(){
			$('#pop').hide();
		});
		
		
		var images = {
				  localId: [],
				  serverId: []
		};
		$('.publish').click(function(){			var zc_id=$(this).attr('current_id');			if(zc_id==null){				zc_id=0;			}			else{				var is_up=1;				$.ajax({									type:'post',									url:'index.php?act=upload&op=upload_check&zc_id='+zc_id,									data:{pdata:zc_id},									dataType:'json',									async:false,									success:function(data){											var zc_start_time=parseInt(data.start_time);											var zc_end_time=parseInt(data.end_time);											var current_time=parseInt(data.current_time);																															var start_obj=new Date(zc_start_time*1000);											var start_y=start_obj.getFullYear();											var start_m=start_obj.getMonth()+1;											var start_d=start_obj.getDate();											var start_h=start_obj.getHours();											var start_i=start_obj.getMinutes();																						var current_obj=new Date(current_time*1000);											var current_y=current_obj.getFullYear();											var current_m=current_obj.getMonth()+1;											var current_d=current_obj.getDate();											var current_h=current_obj.getHours();											var current_i=current_obj.getMinutes();																						var end_obj=new Date(zc_end_time*1000);											var end_y=end_obj.getFullYear();											var end_m=end_obj.getMonth()+1;											var end_d=end_obj.getDate();											var end_h=end_obj.getHours();											var end_i=end_obj.getMinutes();																						var zc_start_gsh=start_y+"-"+start_m+"-"+start_d+" "+start_h+":"+start_i;											var zc_current_gsh=current_y+"-"+current_m+"-"+current_d+" "+current_h+":"+current_i;											var zc_end_gsh=end_y+"-"+end_m+"-"+end_d+" "+end_h+":"+end_i;																					if(zc_start_time<current_time && current_time<zc_end_time){											is_up=0;											alert("专场开始时间："+zc_start_gsh+"\r\n当前时间："+zc_current_gsh+"\r\n专场结束时间："+zc_end_gsh+"\r\n专场正在进行！！");											return false;										}										else if(current_time>zc_end_time){											is_up=0;											alert("专场开始时间："+zc_start_gsh+"\r\n当前时间："+zc_current_gsh+"\r\n专场结束时间："+zc_end_gsh+"\r\n专场结束了！！");											return false;										}										else if(zc_start_time>zc_end_time){											is_up=0;											alert("专场开始时间："+zc_start_gsh+"\r\n当前时间："+zc_current_gsh+"\r\n专场结束时间："+zc_end_gsh+"\r\n专场异常！！");											return false;										}										else{is_up=1;}									}								});			if(is_up==0){return false;}			}			
			  var isauth = '<?php echo $output['isauth'];?>';
			  if(isauth == '0'){
				 location.href = 'index.php?act=index&op=mobile';
			  	 return false;
			  }

			  var is_btwoc = parseInt('<?php echo $output['is_btwoc']?>');
			  if(is_btwoc=='1'){
			  		var user_is_btwoc = '<?php echo $output['user']['is_btwoc']?>';
			  		if(user_is_btwoc=='0'){
						alert('您不是平台审核的商家，请联系平台为您开通');
						return false;
				  	}
			  }	
			  
			  wx.chooseImage({
				    success: function (res) {
				      	images.localId = res.localIds;
				      	if (images.localId.length == 0) {
				          alert('请先使用 chooseImage 接口选择图片');
				          return;
				        }
		            	$('.readynumpic').html(0);
		            	$('.totalpic').html(images.localId.length);
				        $('.loaddingBg').show();  
				        var i = 0, length = images.localId.length;
				        images.serverId = [];
				        function upload() {
				          wx.uploadImage({
				            localId: images.localId[i],
				            isShowProgressTips: 0,
				            success: function (res) {
				              i++;
				              images.serverId.push(res.serverId);
				              $('.readynumpic').html(i);
				              $('.totalpic').html(length);
				              if (i < length) {
				                	upload();
				              }else{
								var str = images.serverId;
								var pdata = str.join(',');

								$.ajax({
									type:'post',
									url:'index.php?act=upload&op=addauction&zc_id='+zc_id,
									data:{pdata:pdata},
									dataType:'json',
									success:function(data){
										if(data.state){
											location.href = 'index.php?act=publish&auction_id='+data.auction_id+'&zc_id='+zc_id;
										}								
										return false;										
									}
								});
					          }
				            },
				            fail: function (res) {
				              alert(JSON.stringify(res));
				            }
				          });
				        }

				        upload();				    	        
				    }
			  });
		});

		<?php if(!empty($_GET['auction_id'])){?>
	 	  wx.onMenuShareAppMessage({
				title:"<?php echo $output['one_auction']['auction_description'];?>",
			    desc: "<?php echo $output['one_auction']['auction_description'];?>",
			    link: "<?php echo BASE_SITE_URL;?>/index.php?act=index&auction_id=<?php echo $output['one_auction']['id'];?>",
			    imgUrl: "<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['one_auction']['auction_add_date'].'/'.$output['one_auction']['auction_img1'];?>",
			    trigger: function (res) {
			      //alert('用户点击发送给朋友');
			    },
			    success: function (res) {
				      var auction_id = '<?php echo $output['one_auction']['id'];?>';
				      $.ajax({
							type:'get',
							url:'index.php?act=index&op=share',
							data:{auction_id:auction_id},
							success:function(){
								return false;
							}
						  });
				      $('#pop').hide();

			    },
			    cancel: function (res) {
			      $('#pop').hide();
			    },
			    fail: function (res) {
			      	//alert(JSON.stringify(res));
			    }
			  });

	 	  wx.onMenuShareTimeline({
			    title: "<?php echo $output['one_auction']['auction_description'];?>",
			    link: "<?php echo BASE_SITE_URL;?>/index.php?act=index&auction_id=<?php echo $output['one_auction']['id'];?>",
			    imgUrl: "<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['one_auction']['auction_add_date'].'/'.$output['one_auction']['auction_img1'];?>",
	 		    success: function () { 
			      $.ajax({
						type:'get',
						url:'index.php?act=index&op=share',
						data:{auction_id:auction_id},
						success:function(){
							return false;
						}
					  });
			      $('#pop').hide();
	 		        // 用户确认分享后执行的回调函数
	 		    },
	 		    cancel: function () { 
	 		    	$('#pop').hide();
	 		        // 用户取消分享后执行的回调函数
	 		    }
	 	 });
		<?php }?>


		<?php if(!empty($_GET['seller_id'])){?>
	 	  wx.onMenuShareAppMessage({
			    title: "【<?php echo $output['seller']['nickname'];?>】的<?php echo $output['site_name'];?>开拍喽！",
			    link: "<?php echo BASE_SITE_URL;?>/index.php?act=shop&seller_id=<?php echo $output['seller']['user_id'];?>",
			    imgUrl: "<?php echo $output['seller']['avatar']?>",
			    trigger: function (res) {
			      //alert('用户点击发送给朋友');
			    },
			    success: function (res) {
				      $('#pop').hide();

			    },
			    cancel: function (res) {
			      $('#pop').hide();
			      //alert('已取消');
			    },
			    fail: function (res) {
			      	//alert(JSON.stringify(res));
			    }
			  });

	 	  wx.onMenuShareTimeline({
			    title: "【<?php echo $output['seller']['nickname'];?>】的<?php echo $output['site_name'];?>拍卖开拍拉！",
			    link: "<?php echo BASE_SITE_URL;?>/index.php?act=shop&seller_id=<?php echo $output['seller']['user_id'];?>",
			    imgUrl: "<?php echo $output['seller']['avatar']?>",
	 		    success: function () { 
			      $('#pop').hide();
	 		        // 用户确认分享后执行的回调函数
	 		    },
	 		    cancel: function () { 
	 		    	$('#pop').hide();
	 		        // 用户取消分享后执行的回调函数
	 		    }
	 	 });
		<?php }?>
});
</script>


